{{>header}}

<div class="edit main" id="edit">
<form action="/comment/edit/{{comment._id}}" method="post" class="commentForm">
    <textarea name="content">{{#if comment.atUser._id}}@{{comment.atUser.name}}&nbsp;{{/if}}{{comment.content}}</textarea>
    {{#if comment.atUser}}
        <input type="hidden" name="atUserId" value="{{comment.atUser._id}}"/>
    {{/if}}
    <input type="submit" value="提交"/>
    <span class="errorMsg"></span>
</form>
</div>

{{>editSide}}

{{#section 'script'}}
<script>
    $(function(){
        var limit=[{{postCharacterLengthLimit.comment}}];
        $('#edit').on('submit','.commentForm',function(){
            var content=$(this).find('textarea').val();
            if(!content || content.length<limit[0] || content.length>limit[1]){
                $(this).find('.errorMsg').text(['评论内容长度非法(',limit[0],'~',limit[1],')'].join('')).show();
                return false;
            }
        });
    });
</script>
{{/section}}